package com.eptok.gw.szcups.cups.busi.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import ys8583.parse.IOMessage;

import com.eptok.gw.szcups.common.GateWayConstant;
import com.eptok.gw.szcups.common.KeyContainer;
import com.eptok.gw.szcups.cups.CupsMessageControl;
import com.eptok.gw.szcups.cups.busi.CupsBusiInterface;
import com.eptok.gw.szcups.cups.message.MacGenerator;
import com.eptok.gw.szcups.socket.client.factory.ClientFactory;
import com.eptok.gw.szcups.util.DateUtil;

/**
 * 建立委托关系/撤销委托关系通知		业务处理
 * 
 *@author:heqishan, Email:heqishan@gmail.com
 *2013-3-24 下午04:05:44
 */
public class ReliationshipNotifyBusiImpl implements CupsBusiInterface {
	
	private static final Logger log = LoggerFactory.getLogger(ReliationshipNotifyBusiImpl.class);

	public void dobusiness(IOMessage ioMessage) {
		//TODO 业务处理
		
		//返回响应给银联
		try {
			ioMessage.setRspMap(ioMessage.getReqMap());
			ioMessage.setRspMessageID(GateWayConstant.MSG_CODE_RELATIONSHIP_NOTIFY_RSP);
			ioMessage.setRspField(7, DateUtil.formatDate("MMddHHmmss"));
			ioMessage.setRspField(12, DateUtil.formatDate("HHmmss"));						//本地交易时间	hhmmss
			ioMessage.setRspField(13, DateUtil.formatDate("MMdd"));							//本地交易日期	MMDD
			
			ioMessage.setRspField(39,GateWayConstant.FIELD_39_SUCCESS);						//返回代码
			new MacGenerator().generateMarchantMac(ioMessage,KeyContainer.getInstance().getMerZAK());
			ClientFactory.getInstance().sendMessage(CupsMessageControl.PASSIVE_MERCHAN_CLIENT_KEY, ioMessage);
		} catch (Exception e) {
			log.error("返回响应信息给银联失败",e);
		}
	}

}
